<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<div id="cnavbar" th:fragment="cnavbar" class="header">

    <span th:if="${CURRENT_CUSTOMER == null}">
        <span id="no_login"></span>
    </span>
    <link rel="stylesheet" th:href="@{/cweb/css/shutter.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/public.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/header.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/index.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/footer.css}"/>
    <link rel="stylesheet" th:href="@{/libs/bootstrap/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/cweb/css/zeroModal.css}"/>
    <div class="content">
        <!-- 此logo 暂时写死  -->
        <img class="logo" th:src="@{/cweb/img/logo.jpg}" alt=""/>
        <div class="main-nav-div">
            <ul class="main-nav" style="margin-bottom: 0px">
                <!--首页固定-->
                <a th:href="@{/}">
                    <li th:class="${categoryId=='index' ? 'th-bg' : ''}"><span>首页</span></li>
                </a>

                <!--后台去掉多级菜单-->
                <a th:each="category:${CATEGORY_LIST}" th:href="@{${('/blog/category/' + category.id)}}">
                    <li th:class="${category.id==categoryId ? 'th-bg': ''}">
                        <span th:text="${category.name}"></span>
                    </li>
                </a>
                <!--以下固定-->
                <a th:href="@{/blog/calculator}">
                    <li id="tdr">碳达人</li>
                </a>
                <a th:href="@{/blog/aboutus}">
                    <li id="gywo">关于我们</li>
                </a>
                <a th:href="@{/blog/contactus}">
                    <li id="lxwo">联系我们</li>
                </a>
                <!--判断是否登录-->
                <!--<a th:href="@{/blog/regist}" th:class="${categoryId=='regist' ? 'th-bg' : ''} "><li>注册</li></a>-->

                <span th:unless="${CURRENT_CUSTOMER == null}">
                    <div class="user-info-div">
                        <img th:src="@{/img/user.png}" alt="..." class="img-circle user-img">
                        <div class="user-name">
                            <div>
                                <div class="user-name-text" th:text="${CURRENT_CUSTOMER.nicname}"></div>
                                <span class="label label-danger" style="float: left">企业会员</span>
                            </div>
                            <div class="username-text" th:text="${CURRENT_CUSTOMER.username}"></div>
                        </div>
                    </div>
                    <div class="user-info-dialog">
                        <img th:src="@{/img/user.png}" alt="..." class="img-circle">
                        <div class="user-name">
                            <div>
                                <div class="user-name-text" th:text="${CURRENT_CUSTOMER.nicname}"></div>
                                <span class="label label-danger" style="float: left">企业会员</span>
                            </div>
                            <div th:text="${CURRENT_CUSTOMER.username}" class="username-text"></div>
                        </div>
                        <div class="logout-div">
                            <i class="glyphicon glyphicon-log-in"></i>&nbsp;<span onclick="userLogout()"
                                                                                  style="cursor: pointer">退出登录</span>
                        </div>
                    </div>
                </span>
            </ul>
            <span th:if="${CURRENT_CUSTOMER == null}">
                <div class="regist-div" onclick="userLogin();">
                    登录
                </div>
            </span>
        </div>
        <div class="cf"></div>
    </div>
    <script th:inline="javascript">let ctx = [[@{/}]];</script>
    <script th:src="@{/cweb/js/jquery-3.2.1.min.js}"></script>
    <script th:src="@{/libs/layer/layer.js}"></script>
    <script th:src="@{/cweb/js/zeroModal.min.js}"></script>
    <script>
        let sendBtn;
        let sendUsername;
        let pagecode;
        let by;

        function userRegist() {
            zeroModal.closeAll();
            zeroModal.show({
                title: '',
                width: '465px',
                url: '[[@{/blog/regist}]]',
                height: '700px',
            });
        }

        function userLogin() {
            zeroModal.closeAll();
            zeroModal.show({
                title: '',
                width: '465px',
                url: '[[@{/blog/login}]]',
                height: '490px',
                onClosed: function () {
                    //window.location.href = '/';
                }
            });
        }

        function userLogout() {
            zeroModal.show({
                title: '退出登录',
                content: '确定退出登录？',
                width: '200px',
                height: '140px',
                ok: true,
                okFn: function () {
                    //退出登录
                    Core.postAjax("/blog/api/logout/input", {}, function (data) {
                        layer.msg(data.msg, {
                            offset: '30%',
                            time: 800
                        }, function () {
                            if (data.status == 200) {
                                //刷新当前页面
                                location.reload();
                                console.info(data);
                            }
                        });
                    });
                },
                cancel: true
            });
        }

        $(function () {
            $('.user-info-div').mouseover(function () {
                $('.user-info-dialog').show();
            });
            $('.user-info-div').mouseout(function () {
                $('.user-info-dialog').hide();
            });
            $('.user-info-dialog').mouseover(function () {
                $('.user-info-dialog').show();
            });
            $('.user-info-dialog').mouseout(function () {
                $('.user-info-dialog').hide();
            });

        });

        let xz0_1_validator = {
            callback: function (value, validator, $field) {
                let r = /^[0-9]+\.[0-9]{2}$/;
                if (!value || value < 0 || value > 1 || !r.test(value)) {
                    return {
                        valid: false,
                        message: '请输入0到1的两位小数'
                    }
                } else {
                    return true
                }
            }
        }

        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?d392b2f2725f52075c9c170bcd76c347";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</div>
</html>